// import * as Mock from 'mockjs'
import { config } from '@/config/axios/config'
const { result_code } = config

// 模拟返回的数据格式，可以自己随便定义
const term = {
  '202220231': [
    {
      id: 1,
      school: '云龙学校',
      numPeople: 1324,
      levelD: 10,
      incomplete: 2,
      completion: '99%'
    },
    {
      id: 2,
      school: '实验学校',
      numPeople: 2388,
      levelD: 37,
      incomplete: 13,
      completion: '93%'
    },
    {
      id: 3,
      school: '师范学校',
      numPeople: 1549,
      levelD: 50,
      incomplete: 16,
      completion: '91%'
    },
    {
      id: 4,
      school: '歌风学校',
      numPeople: 2062,
      levelD: 46,
      incomplete: 4,
      completion: '82%'
    },
    {
      id: 5,
      school: '技术学校',
      numPeople: 2315,
      levelD: 32,
      incomplete: 1273,
      completion: '45%'
    },
    {
      id: 6,
      school: '职业学校',
      numPeople: 2012,
      levelD: 48,
      incomplete: 2,
      completion: '86%'
    },
    {
      id: 7,
      school: '开发学校',
      numPeople: 2652,
      levelD: 33,
      incomplete: 5,
      completion: '98%'
    },
    {
      id: 8,
      school: '交通学校',
      numPeople: 1670,
      levelD: 38,
      incomplete: 12,
      completion: '80%'
    }
  ],
  '202220232': [
    {
      id: 1,
      school: '云龙学校',
      numPeople: 1324,
      levelD: 20,
      incomplete: 2,
      completion: '99%'
    },
    {
      id: 2,
      school: '实验学校',
      numPeople: 2388,
      levelD: 37,
      incomplete: 13,
      completion: '93%'
    },
    {
      id: 3,
      school: '师范学校',
      numPeople: 1549,
      levelD: 50,
      incomplete: 16,
      completion: '91%'
    },
    {
      id: 4,
      school: '歌风学校',
      numPeople: 2062,
      levelD: 46,
      incomplete: 4,
      completion: '82%'
    },
    {
      id: 5,
      school: '技术学校',
      numPeople: 2315,
      levelD: 32,
      incomplete: 18,
      completion: '95%'
    },
    {
      id: 6,
      school: '职业学校',
      numPeople: 2012,
      levelD: 48,
      incomplete: 2,
      completion: '86%'
    },
    {
      id: 7,
      school: '开发学校',
      numPeople: 2652,
      levelD: 33,
      incomplete: 5,
      completion: '98%'
    },
    {
      id: 8,
      school: '交通学校',
      numPeople: 1670,
      levelD: 38,
      incomplete: 12,
      completion: '80%'
    }
  ],
  '202120222': [
    {
      id: 1,
      school: '云龙学校',
      numPeople: 1324,
      levelD: 30,
      incomplete: 2,
      completion: '99%'
    },
    {
      id: 2,
      school: '实验学校',
      numPeople: 2388,
      levelD: 37,
      incomplete: 13,
      completion: '93%'
    },
    {
      id: 3,
      school: '师范学校',
      numPeople: 1549,
      levelD: 50,
      incomplete: 16,
      completion: '91%'
    },
    {
      id: 4,
      school: '歌风学校',
      numPeople: 2062,
      levelD: 46,
      incomplete: 4,
      completion: '82%'
    },
    {
      id: 5,
      school: '技术学校',
      numPeople: 2315,
      levelD: 32,
      incomplete: 18,
      completion: '95%'
    },
    {
      id: 6,
      school: '职业学校',
      numPeople: 2012,
      levelD: 48,
      incomplete: 2,
      completion: '86%'
    },
    {
      id: 7,
      school: '开发学校',
      numPeople: 2652,
      levelD: 33,
      incomplete: 5,
      completion: '98%'
    },
    {
      id: 8,
      school: '交通学校',
      numPeople: 1670,
      levelD: 38,
      incomplete: 12,
      completion: '80%'
    }
  ]
}

export default [
  {
    url: '/school/schoolList',
    method: 'get',
    response: () => {
      //const t = params.query.term

      return {
        code: result_code,
        data: term
      }
    }
  },
  {
    url: '/school/schoolList',
    method: 'post',
    response: (params) => {
      const t = params.body
      if (term[t['学期']] == null) term[t['学期']] = []
      term[t['学期']].push({
        id: t['学校id'],
        school: t['学校'],
        numPeople: t['总人数'],
        levelD: t['未做完人数'],
        incomplete: t['未做完人数'],
        completion: Number(t['完成率'] * 100).toFixed(1) + '%'
      })
      return {
        code: result_code,
        data: term
      }
    }
  }
]
